<%@page import="ca.concordia.soen6461.wichf.navigation.view.CartView"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@page import="ca.concordia.soen6461.wichf.navigation.view.CheckoutView"%>
<%   
   // CheckoutView view = new CheckoutView();
   // request.setAttribute("view", view.render(null));
%>
<% CheckoutView.Bean view = (CheckoutView.Bean) request.getAttribute("view"); %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<jsp:include page="/header.jsp"></jsp:include>
<a href="?event=HomeEvent">Home</a>
<a href="?event=BackEvent">Back</a>
<form name="check" action="./" method="POST">
<jsp:include page="/messages.jsp"></jsp:include>
<h3><font color="red">Selected Appointments :</font></h3>
<table align=center cellpadding=5 cellspacing=0 bgcolor="#D5FFD5">

<tr>
<td>Type Of Appointment</td>

<td>Date</td>

<td>Amount</td>

</tr>
<%
  for(int i=0; i < view.getAppointments().size(); i++) {
    CartView.Appointment appointment = view.getAppointments().get(i);
%>
	<tr>
      <td><%=appointment.getType()%><input type="hidden" name="item.<%=appointment.getItem()%>"/></td>
	  <td><%=appointment.getDate()%></td>
      <td><%=appointment.getPrice()%></td>
    </tr>
<%
  }
%>
<tr><td></td>
<td>total :</td>
<td><%=view.getTotal()%></td>
</tr>
<tr>
<td>Card Holder's Name:</td><td> <input type="text" name="card_name"></td>
</tr>
<tr><td>Card No:</td><td> <input type="text" name="card_no" /></td>
</tr>
<tr><td>CVV :</td><td> <input type="text" name="cvv"></td>
</tr>

<tr>
<td>ExpiryDate(Format - MM/YY) :</td><td> <input type="text" size="1" name="expiry_month" /> / <input type="text" size="1" name="expiry_year" /></td>
</tr>
<tr>
<td>
<input type="submit" onclick="paymentconformed()" name="PayEvent" value="Pay"></td>
</tr>
</table>
</form>
<script type="text/javascript">
function paymentconformed()
{
	if(document.check.card_name.value==""){
		alert("please enter valid card name");
		return document.check.card_name.focus();
	}
	if(document.check.card_no.value==""){
		alert("please enter valid card number");
		return document.check.card_no.focus();
	}
	if(document.check.cvv.value==""){
		alert("please enter valid card code");
		return document.check.cvv.focus();
	}
	if(document.check.expiry_month.value==""){
		alert("please enter expiry date");
		return document.check.expiry_month.focus();
	}
	if(document.check.expiry_year.value==""){
		alert("please enter expiry date");
		return document.check.expiry_year.focus();
	}
	document.forms[0].submit();
	}



</script>
</body>
</html>